/*
 * GeneticAlgorithmAdvancedParameters.h
 *
 *  Created on: Oct 21, 2013
 *      Author: filipe
 */

#ifndef GENETICALGORITHMADVANCEDPARAMETERS_H_
#define GENETICALGORITHMADVANCEDPARAMETERS_H_

#include "MutationStrategy.h"
#include "SelectionStrategy.h"
#include "CrossoverStrategy.h"
#include "DiversityAnalysis.h"

namespace EvolutionaryOptimization
{
	template<class T>
	class GeneticAlgorithmAdvancedParameters
	{
		protected:

			int _NumMaxGenerations;
			double _CrossoverProbability;
			double _MutationProbability;

			SelectionStrategy *_Selector;
			MutationStrategy<T> *_Mutation;
			CrossoverStrategy<T> *_Crossover;
			DiversityAnalysis *_DiversityAnalyser;

			// TODO: pesquisar por que isso nao funcionou!
			// virtual void _CreateDefaultStrategyParameters() = 0;

		public:

			GeneticAlgorithmAdvancedParameters()
			{
				_NumMaxGenerations = 100;
				_MutationProbability = 0.01;
				_CrossoverProbability = 0.6;
			}


			GeneticAlgorithmAdvancedParameters(int num_max_generations)
			{
				_NumMaxGenerations = num_max_generations;
				_MutationProbability = 0.01;
				_CrossoverProbability = 0.6;
			}


			GeneticAlgorithmAdvancedParameters(int num_max_generations, double crossover_probability, double mutation_probability)
			{
				_NumMaxGenerations = num_max_generations;
				_CrossoverProbability = crossover_probability;
				_MutationProbability = mutation_probability;
			}


			GeneticAlgorithmAdvancedParameters(
					int num_max_generations,
					double crossover_probability,
					double mutation_probability,
					MutationStrategy<T> *mutation,
					SelectionStrategy *selector,
					CrossoverStrategy<T> *crossover,
					DiversityAnalysis *diversity_analyser)
			{
				_Mutation = mutation;
				_Selector = selector;
				_Crossover = crossover;
				_DiversityAnalyser = diversity_analyser;
				_NumMaxGenerations = num_max_generations;

				_MutationProbability = mutation_probability;
				_CrossoverProbability = crossover_probability;
			}


			virtual ~GeneticAlgorithmAdvancedParameters()
			{
				delete(_Mutation);
				delete(_Selector);
				delete(_Crossover);
				delete(_DiversityAnalyser);
			}


			CrossoverStrategy<T>*
			GetCrossover() const
			{
				return _Crossover;
			}


			void
			SetCrossover(CrossoverStrategy<T>* crossover)
			{
				_Crossover = crossover;
			}


			DiversityAnalysis*
			GetDiversityAnalyser() const
			{
				return _DiversityAnalyser;
			}


			double
			GetMutationProbability() const
			{
				return _MutationProbability;
			}


			double
			GetCrossoverProbability() const
			{
				return _CrossoverProbability;
			}


			void
			SetDiversityAnalyser(DiversityAnalysis* diversityAnalyser)
			{
				_DiversityAnalyser = diversityAnalyser;
			}


			MutationStrategy<T>*
			GetMutation() const
			{
				return _Mutation;
			}


			void
			SetMutation(MutationStrategy<T>* mutation)
			{
				_Mutation = mutation;
			}


			int
			GetNumMaxGenerations() const
			{
				return _NumMaxGenerations;
			}


			void
			SetNumMaxGenerations(int numMaxGenerations)
			{
				_NumMaxGenerations = numMaxGenerations;
			}


			SelectionStrategy*
			GetSelector() const
			{
				return _Selector;
			}


			void
			SetSelector(SelectionStrategy* selector)
			{
				_Selector = selector;
			}


			void
			SetMutationProbability(double mutation_probability)
			{
				_MutationProbability = mutation_probability;
			}


			void
			SetCrossoverProbability(double crossover_probability)
			{
				_CrossoverProbability = crossover_probability;
			}
	};
}

#endif
